package com.bxs.dao;

import com.bxs.dao.db.SaveMsgToDBHandler;
import com.bxs.pojo.DangerMsg;

import java.util.ArrayList;
import java.util.List;

// 数据存储引擎
public class DataSaveEngine {
    private List<BaseDataHandler> dataHandlers = new ArrayList<BaseDataHandler>();

    public void execute(DangerMsg data){
        for(BaseDataHandler handler : dataHandlers){
            handler.handleData(data);
        }
    }

    public void register(BaseDataHandler dataHandler){dataHandlers.add(dataHandler);}

    public void setDataHandlers(List<BaseDataHandler> dataHandlers) {
        this.dataHandlers = dataHandlers;
    }
}
